#include <iostream>
#include <map>

typedef std::map<std::string, int> TestMap;
typedef TestMap::iterator TestMapIter;
typedef TestMap::value_type TestMapVal;

int main(int argc, char *argv[])
{
	TestMap test;
	test.insert({"a", 1});
	std::pair<TestMapIter, bool> res = test.insert(TestMapVal("b", 2));
	std::cout << "Insert key:" << (res.first)->first << (res.second ? " succeeded\n" : " failed\n");

	// key 已经存在时, insert() 会失败
	res = test.insert(TestMapVal("b", 3));
	std::cout << "Insert key:" << (res.first)->first << (res.second ? " succeeded\n" : " failed\n");

	for (auto it = test.begin(); it != test.end(); it++)
	{
		std::cout << it->first << ":" << it->second<< std::endl;	
	}
	return 0;
}

